<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="dialogFormVisible"
      width="30%"
      @close="clear"
    >
      <el-form :model="form">
        <el-form-item label="时间" :label-width="formLabelWidth">
          <el-date-picker
            v-model="form.date"
            type="date"
            @change="chooseTime()"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            placeholder="选择日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="用户名" :label-width="formLabelWidth">
          <el-input v-model="form.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="角色名" :label-width="formLabelWidth">
          <el-input v-model="form.role" autocomplete="off"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="clear">取 消</el-button>
        <el-button type="primary" @click="sure()">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'ManageDialog',
  props: {
    title: String,
  },
  data() {
    return {
      dialogFormVisible: false,
      form: {
        date: '',
        name: '',
        role: '',
      },
      formLabelWidth: '120px',
    };
  },

  mounted() {},

  methods: {
    chooseTime() {
      // console.log(e);
    },
    clear() {
      this.dialogFormVisible = false;
      this.form = {};
    },
    sure() {
      const params = Object.assign({}, this.form, { edit: true });
      this.$emit('add', params);
      this.clear();
    },
  },
};
</script>

<style lang="scss" scoped></style>
